#pragma once
#include "ximage.h"

// CODEdit

class CODEdit : public CEdit
{
	DECLARE_DYNAMIC(CODEdit)

	enum CtrlState 
	{
		stateNormal,
		stateFocus,
	};
public:
	CODEdit();
	virtual ~CODEdit();

	BOOL SetEditArea(int nMarginLeft,int nMarginTop,int nMarginRight,int nMarginBottom);
    void SetImage(CString sImageFile);
protected:
	void ResizeWindow(int cx,int cy);

	virtual void OnDraw(CDC* pDC);

protected:
	int m_nMarginLeft;
	int m_nMarginTop;
	int m_nMarginRight;
	int m_nMarginBottom;
	CtrlState	m_eStateEdit;
    CxImage m_imgBk;
protected:
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	afx_msg void OnEnSetfocus();
	afx_msg void OnEnKillfocus();
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};


